<template>
	<view id="certificationMoney">
		<view class="warring_txt02">
		      注：梦琪科技将通过中国工商银行向您的对公账户转入随机金额(0.01~
		      0.99)元，0~2天到账，请注意查收并回填到账金额
		</view>
		<view class="center">
			<view class="item">
				<text>汇款账户名</text>
				<view class="input">梦琪科技有限公司</view>
			</view>
			<view class="item">
				<text>汇款银行</text>
				<view class="input">中国工商银行</view>
			</view>
			<view class="item">
				<text>汇款账号</text>
				<view class="input">202205809900047634</view>
			</view>
			<view class="item">
				<text>到账账号</text>
				<view class="input">
					{{cert.bankAccount}}
				</view>
			</view>
			<view class="item">
				<text>填写到账金额</text>
				<input class="input2" type="text" value="" placeholder="输入金额" v-model="account_num"/>
			</view>
			<view class="no_curr" v-if="numberverifyCount > 0 && numberverifyCount < 3">
			        到账金额输入不正确，建议您再次提交到账金额,剩余尝试次数{{ 3-numberverifyCount }}次
			</view>
			<view class="no_curr" v-if="numberverifyCount == 3">
			        到账金额输入不正确，剩余尝试次数0次，请重新进行认证
			</view>
			<button type="primary" v-if="numberverifyCount==0" @click="submitSert">提交认证</button>
			<button type="primary" v-if="numberverifyCount==3" @click="submitSertRe">重新认证</button>
			<button type="primary" v-if="numberverifyCount > 0 && numberverifyCount < 3" @click="submitSert">再次认证</button>
			<button type="primary" v-if="numberverifyCount > 0 && numberverifyCount < 3" @click="submitSertRe">取消认证</button>
		</view>		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cert:{
					bankAccount:''
				},
				account_num:'',
				numberverifyCount:''
			}
		},
		onShow(){
			this.getPersonalCertify()
			this.verifyCount()
			setTimeout(function() {console.log(this.numberverifyCount);}, 1000);
			
		},
		methods: {
			submitSertRe() {
			      let that = this;
				  uni.showModal({
				      title: '此操作将删除原有认证信息',
				      content: '是否继续?',
					  confirmText:"确定",
					  cancelText:'取消',
				      success: function (res) {
						  console.log(res);
				          if (res.confirm) {
				             that.$store
				               .dispatch("AgainCetify")
				               .then((response) => {
				             	if(response.data.code==0){
				             		let data = response.data.obj;
				             		that.cert = data;
									uni.navigateTo({
										url: "/pagesA/user/certIput"
									})			
				             	}
				               })
				               .catch(() => {}); 
							  console.log('用户点击确定');
				          } else if (res.cancel) {
				              console.log('用户点击取消');
				          }
				      }
				  });
			      this.$dialog.confirm({
			        mes: "此操作将删除原有认证信息, 是否继续?",
			        opts: () => {
			          againCetify().then((response) => {
			            let data = response;
			            if (data.code == "0") {
			              that.$router.push("/certInput");
			            } else {
			              this.$message({
			                showClose: true,
			                message: data.msg,
			                type: "error",
			              });
			              return false;
			            }
			          });
			        },
			      });
			},
			getPersonalCertify(){
				let that = this;
				this.$store
				  .dispatch("BusinessCetifyGet")
				  .then((response) => {
					if(response.data.code==0){
						let data = response.data.obj;
						that.cert = data;			
					}
				  })
				  .catch(() => {});
			},
			verifyCount(){
				let that = this;
				this.$store
				  .dispatch({
					  type:"verifyCount",
					})
				  .then((response) => {
					if(response.data.code==0){
						let data = response.data.obj;
						that.numberverifyCount = data;
								console.log(that.numberverifyCount);
					}
				  })
				  .catch(() => {});
			},
			submitSert(){
				let that = this;
				if (this.account_num == "") {
					this.$store.commit("SET_ERRORINFORMATION", {
					  mes: "到账金额不能为空",
					  icon: "error",
					});
				    return;
				 }
				let obj = {
				    money: this.account_num,
				};
				this.$store
				  .dispatch({
					  type:"Verify",
					   money: this.account_num
					})
				  .then((response) => {
					if(response.data.code==0){
						this.verifyCount()
						uni.navigateTo({
							url: "/pagesA/user/certIput"
						})
					}else{
						this.verifyCount()	
						this.$store.commit("SET_ERRORINFORMATION", {
						  mes: response.data.msg,
						  icon: "error",
						});
					}
				  })
				  .catch(() => {});
			}
		}
	}
</script>

<style lang="less">
#certificationMoney{
	width: 1005;
	.warring_txt02{
		text-align: left;
		background-color: #ffefe2;
		color: #f28832;
		padding: 20rpx;
		font-size: 24rpx;
	}
  .center{
	  width: 92%;
	  margin: 0 auto;
  }
	.item{
		margin-top: 20rpx;
	}
	.input{
		height: 80rpx;
	    font-size:30rpx;
	    color: #666666;
	    line-height: 80rpx;
		border-bottom: 2rpx solid #e4e5ed;
	}
	.input2{
		height: 80rpx;
		font-size:30rpx;
		color: #666666;
		line-height: 80rpx;
	}
	button{
		margin-top: 50rpx;
		background: #007AFF;
		width: 80%;
	}
	.no_curr{
		font-size: 32rpx;
		color: #fc5d6d;
		margin-bottom: 40rpx;      
	}
}
</style>
